package com.linsen.core.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

@Getter
@AllArgsConstructor
public enum GenderType {
    SECRET(0, "保密"),
    MALE(1, "男"),
    FEMALE(2, "女"),
    ;

    @JsonValue
    private final Integer value;
    private final String desc;

    private static final Map<Integer, GenderType> VALUES = new HashMap<>();

    static {
        for (final GenderType genderType : GenderType.values()) {
            GenderType.VALUES.put(genderType.getValue(), genderType);
        }
    }

    @JsonCreator
    public static GenderType getByValue(Integer value) {
        return GenderType.VALUES.get(value);
    }
}
